package com.ncloud.act.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import com.ncloud.act.entity.WriteOffLog;

@Mapper
public interface WriteOffLogMapper{

	@Select("SELECT writeoff_id, charge_id, acct_id, cycle_id, bill_id, node_id, item_code, deposit_code, acct_balance_id, writeoff_fee,"
			+ "fee, old_balance, new_balance, writeoff_late_balance, date_format(latecal_time, '%Y-%m-%d %H:%i:%s' ) as latecal_time, old_paytag, new_paytag,"
			+ "date_format(operate_time, '%Y-%m-%d %H:%i:%s' ) as operate_time, cancel_tag, remark FROM bi_l_writeofflog "
			+ "where acct_id =#{acctID} order by writeoff_id")
	@Results({
		@Result(column="writeoff_id",property="writeoff_id"),@Result(column="charge_id",property="charge_id"),
		@Result(column="acct_id",property="acct_id"),@Result(column="cycle_id",property="cycle_id"),
		@Result(column="bill_id",property="bill_id"),@Result(column="node_id",property="node_id"),
		@Result(column="item_code",property="item_code"),@Result(column="deposit_code",property="deposit_code"),
		@Result(column="acct_balance_id",property="acct_balance_id"),@Result(column="writeoff_fee",property="writeoff_fee"),
		@Result(column="fee",property="fee"),@Result(column="old_balance",property="old_balance"),
		@Result(column="new_balance",property="new_balance"),@Result(column="writeoff_late_balance",property="writeoff_late_balance"),
		@Result(column="latecal_time",property="latecal_time"),@Result(column="old_paytag",property="old_paytag"),
		@Result(column="new_paytag",property="new_paytag"),@Result(column="operate_time",property="operate_time"),
		@Result(column="cancel_tag",property="cancel_tag"),@Result(column="remark",property="remark")})
	List<WriteOffLog> getWriteOffLogByAcctID(Long acctID);
	
	@Insert(value = "insert into bi_l_writeofflog(writeoff_id, charge_id, acct_id, cycle_id, bill_id, node_id, item_code, deposit_code, acct_balance_id, writeoff_fee, fee, old_balance, new_balance, writeoff_late_balance,old_paytag, new_paytag, operate_time, cancel_tag, remark) "
			+ "values(#{writeoff_id},#{charge_id},#{acct_id},#{cycle_id},#{bill_id},#{node_id},#{item_code},#{deposit_code},#{acct_balance_id},#{writeoff_fee},#{fee},#{old_balance},#{new_balance},#{writeoff_late_balance},#{old_paytag},#{new_paytag},#{operate_time},#{cancel_tag},#{remark})")
    public int insertWriteOffLog(WriteOffLog writeOffLog);
}
